﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace TIFPDFCounter
{
	public partial class ProgressBarCustom : UserControl
	{
		int progress;
		static Color fillColor = Color.Blue;
		
		public ProgressBarCustom()
		{
			InitializeComponent();
			progress = 0;
		}
		public int Value
		{
			get
			{
				return progress;
			}
			set
			{
				progress = value;
				progress = Math.Min(progress, 100);
				progress = Math.Max(progress, 0);
				Refresh();
			}
		}
		void ProgressBarCustomPaint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
			Rectangle fillRect = new Rectangle(ClientRectangle.X + 1, ClientRectangle.Y + 1,
				(int)(progress / 100.0D * (ClientRectangle.Width - 2)), ClientRectangle.Height - 2);
			using (Graphics g = CreateGraphics())
			using (Brush b = new SolidBrush(fillColor))
			{
				g.FillRectangle(b, fillRect);	
			}
		
		}
	}
}
